<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>JS对象测试</title>
</head>
<body>

</body>
<script>
    //定义person
    let person = {
        name: "张三",
        age: 23,
        hobby: ["听课", "学习"],

        eat: function () {
            document.write("吃饭...");
        }
    };

    //使用
    document.write(person.name);
    person.eat();
    document.write("<br>");

    document.write("=============================")
    document.write("<br>");
    //继承测试
    class Person {
        constructor(name, age) {
            this.name = name;
            this.age = age;
        }

        eat() {
            document.write("人吃饭");
        }
    }
    class Worker extends Person{
        constructor(name,age,salary) {
            super(name,age);
            this.salary=salary;
        }

        show(){
            document.write(this.name + "," + this.age +","+this.salary);
            document.write("<br>");
            this.eat();
        }
    }

    let worker = new Worker("张三",23,5000);
    worker.show();
    document.write("<br>");
</script>
</html>